{extend name="main/index" /}
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">Home</a>
            </li>

            <li>
                <a href="{:url('admin/contract/formmachine')}">添加机械合同</a>
            </li>
            <li class="active">用户列表</li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                                <div class="row">
                                    <div class="col-xs-12">
                                        <h3 class="header smaller lighter blue">机械合同</h3>
                                        <div class="table-header">
                                            <!--Results for "Latest Registered Domains"-->
                                        </div>

                                        <div class="table-responsive">
                                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                                <thead>
                                                    <tr>
                                                        <th>ID</th>
                                                        <th>项目名称</th>
                                                        <th>甲方</th>
                                                        <th>乙方</th>
                                                        <th>租赁方式</th>
                                                        <th>租赁地址</th>
                                                        <th>付款方式</th>
                                                        <th>审批流程</th>
                                                        <th>更改状态</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                   {volist name="list" id="v"}
                                                 <tr>
                                                    <td>{$v['id']}</td>
                                                    <td>{$v['project_name']}</td>
                                                    <td>{$v['first_party']}</td>
                                                    <td>{$v['lease_method']}</td>
                                                    <td>{$v['second_party']}</td>
                                                    <td>{$v['address']}</td>
                                                    <td>{$v['payment_method']}</td>
                                                    <td>
                                                        <?= $v['status']==1?'审核中':'审批完成' ?>

                                                    </td>
                                                    <td>
                                                        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                                            <a class="blue" href="{:url('/admin/Contract/detailmachine',['id' => $v['id']])}">
                                                                <i class="icon-zoom-in bigger-130"></i>
                                                            </a>
                                                            <a class="green" href="{:url('/admin/Contract/upmachine',['id' => $v['id']])}">
                                                                <i class="icon-pencil bigger-130"></i>
                                                            </a>

                                                            <a class="red del-btn " data-id="{$v['id']}"  >
                                                                <i class="icon-trash bigger-130"></i>
                                                            </a>
                                                        </div>

                                                        <div class="visible-xs visible-sm hidden-md hidden-lg">
                                                            <div class="inline position-relative">
                                                                <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown">
                                                                    <i class="icon-caret-down icon-only bigger-120"></i>
                                                                </button>

                                                                <ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">
                                                                    <li>
                                                                        <a href="#" class="tooltip-info" data-rel="tooltip" title="View">
                                                                                <span class="blue">
                                                                                    <i class="icon-zoom-in bigger-120"></i>
                                                                                </span>
                                                                        </a>
                                                                    </li>

                                                                    <li>
                                                                        <a href="#" class="tooltip-success" data-rel="tooltip" title="Edit">
                                                                                <span class="green">
                                                                                    <i class="icon-edit bigger-120"></i>
                                                                                </span>
                                                                        </a>
                                                                    </li>

                                                                    <li>
                                                                        <a href="" class="tooltip-error" data-rel="tooltip" title="Delete">
                                                                                <span class="red">
                                                                                    <i class="icon-trash bigger-120"></i>
                                                                                </span>
                                                                        </a>
                                                                    </li>
                                                                </ul>
                                                            </div>
                                                        </div>
                                                    </td>
                                                    <!--<td>-->
                                                        <!--<a href="{:url('admin/node/edit', ['id' => $v['id']])}" class="label label-lg label-purple arrowed">修改</a>-->
                                                        <!--<button data-id="{$v['id']}" class="btn btn-xs btn-danger del-btn" id="btn" onclick="func1()" >删除</button>-->
                                                        <!--<span class="label label-lg label-pink arrowed-right">Large</span>-->
                                                    <!--</td>-->
                                                </tr>
                                                {/volist}
                                                </tbody>

                                            </table>
                                        </div>
                                    </div>
                                </div>
                        </div>
                    </div>
                </div>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div>
{/block}

{block name="myjs"}
<script>
    $('.del-btn').click(function(){
        var ac_id = $(this).attr('data-id');
        console.log(ac_id);

        if (confirm('你确定要 [ 删 除 ] 吗?')) {
            var obj = $(this).parents('tr');
            delAjax(ac_id, obj);
        }

    });


    function delAjax(id,obj) {
        $.ajax({
            type: 'delete',
            url: '/admin/Contract/delectMachine/id/'+id,
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status) {
                    obj.remove();
                } else {
                }
            },
            error: function () {
                alert('AJAX执行失败');
            }
        });
    }
</script>
{/block}